<template>
  <div>
    <el-select v-model="value" placeholder="请选择" @change="changeValue">
<!--   https://cn.vuejs.org/v2/guide/components-custom-events.html   -->
      <el-option
        v-for="item in options"
        :key="item.deptId"
        :label="item.deptName"
        :value="item.deptId">
      </el-option>
    </el-select>
  </div>
</template>

<script>
  import { psDeptList } from "@/api/system/dept"
  export default {
    name: "DeptSelect",
    data() {
      return {
        options: [],
        value: ""
      }
    },
    created() {
    },
    methods: {
      handlerPsDeptList() {
        return psDeptList().then(res => {
          this.options = res.data;
          this.value = res.data[0].deptId;
          return Promise.resolve('success');
        })
      },
      changeValue(newValue) {
        this.$emit('update:deptId', newValue)
      }
    }
  }
</script>

<style scoped>

</style>
